package com.demo.apparel.service.web.Impl;

import com.demo.apparel.entity.Menu;
import com.demo.apparel.mapper.web.MenuMapper;
import com.demo.apparel.service.web.WebMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class WebMenuServiceImpl implements WebMenuService {

    @Autowired
    private MenuMapper menuMapper;

    @Override
    public List<Menu> getMenuTree() {
        // 这里调用你Mapper中定义的递归查询顶级菜单及子菜单
        return menuMapper.selectRootMenus();
    }

    @Override
    public boolean addMenu(Menu menu) {
        return menuMapper.insertMenu(menu) > 0;
    }

    @Override
    public boolean deleteMenu(Integer id) {
        return menuMapper.deleteById(id) > 0;
    }


    @Override
    public boolean updateMenu(Menu menu) {
        return menuMapper.updateMenu(menu) > 0;
    }


}
